<style>
	#divgiohang_update{ width:534px; }
	#divgiohang_update th{ color:#404040 }
	#divgiohang_update h4{ margin:0; color:#404040}
	#divgiohang_update p { margin-top:8px; margin-bottom:0; color:#404040}
	#divgiohang_update img {cursor:pointer;}
</style>
<script>
	$(document).ready(function() {
	$('.capnhatsoluong').click(function (){
	var idSP = $(this).attr("idsp");
	var soluong = $(this).parent().find('#soluong').val();
	var param = 'action=update<?=$lang?>&idSP='+idSP +'&soluong='+soluong;
	//alert (param);
	$("#giohangan").load("taosession.php",param);
	alert("<? if($lang=='vi') echo 'Cập nhật thành công'; else echo 'Update success!!!';?>");
	window.location.reload();
	})
	 $(".removesp").click(function(){
	var idSP = $(this).attr("idsp");
	var param = "action=remove&idSP="+idSP;
	 $("#giohangan").load("taosession.php",param);
	alert("<? if($lang=='vi') echo 'Xóa thành công'; else echo 'Delete success!!!';?>");
	window.location.reload();
	   })
	$('#btnmuahang').click(function (){
	document.location='dat-hang.html';
})
});
</script>
<div class="right">
<div class="title_right">
	<h1 style="float:left;margin-left:50px;">Chi tiết giỏ hàng</h1>
</div>
<div class="content_right">
	<?php  if ( count($_SESSION['daySoLuong'])<=0) { ?>
<p>Bạn chưa chọn sản phẩm nào</p>
<?php } else { ?>
    <table width=99% border=1 align=center cellpadding=3 cellspacing=0 id=tblgiohang style="margin-top:10px;" bordercolor="#CCCCCC">
    <tr>
    <th width=254><? if($lang=='vi') echo 'Sản phẩm'; else echo 'Products';?></th>
    <th width=155><? if($lang=='vi') echo 'Đơn giá'; else echo 'Price';?></th>
    <th width=199><? if($lang=='vi') echo 'Số lượng'; else echo 'Quantity';?></th>
    <th width=203><? if($lang=='vi') echo 'Thành tiền'; else echo 'Money';?></th>
    </tr>
    <?php
    $sosp = count( $_SESSION['daySoLuong'] );
    reset( $_SESSION['daySoLuong'] );  reset( $_SESSION['dayDonGia'] );
    reset( $_SESSION['dayTenSP'] );    reset( $_SESSION['dayMoTa'] );
    reset( $_SESSION['dayUrlHinh'] ); reset( $_SESSION['dayGiamGia'] );
    $tongtien = $tongsoluong = 0;
    for ($i = 0; $i<$sosp ; $i++) {
        $idSP = key( $_SESSION['daySoLuong'] );
        $tensp = current( $_SESSION['dayTenSP'] );
        $urlhinh = current( $_SESSION['dayUrlHinh'] );
        $images=explode(",",$urlhinh);
		$thum=$images[0];
		$mota = current( $_SESSION['dayMoTa'] );
        $soluong = current( $_SESSION['daySoLuong'] );
        $dongia = current( $_SESSION['dayDonGia'] );
        $tien = $dongia*$soluong;
        $tongtien+= $tien;
        $tongsoluong+= $soluong;
    ?>
    <tr>
      <td>
        <img src="<?=$thum;?>" align=left width=80 height=50>
        <h4> <?=$tensp;?> </h4>
       <p> <?=$mota;?> </p>
      </td>
     <td align="center"><?=number_format($dongia,0,",",".");?> <? //=$sp->KyHieuTienTe;?> </td>
      <td align="center">
        <form action="" id="formUpdate" style= "margin:0">
             <input name="soluong" id="soluong" value="<?=$soluong;?>" size=2 >
             <input name="listid" type="hidden" value="<?=$idSP;?>" />
             <img id="updatecart" title="Update" src="images/refresh.gif" class="capnhatsoluong" alt="Update" idsp="<?=$idSP;?>"/>
             <img title="Delete" src="images/remove.gif" class="removesp" alt="Delete" idsp="<?=$idSP;?>"/>
        </form>
       </td>
      <td align="center"><?=number_format($tien,0,",",".");?> <? //=$sp->KyHieuTienTe;?> </td>
    </tr>
    <?php
         next( $_SESSION['daySoLuong'] );  next( $_SESSION['dayDonGia'] );
         next( $_SESSION['dayTenSP'] );    next( $_SESSION['dayMoTa'] );
         next( $_SESSION['dayUrlHinh'] );	next( $_SESSION['dayGiamGia'] );
    }  //for

    ?>
    <tr class="tongket">
      <th><? if($lang=='vi') echo 'Tổng tiền'; else echo 'Total';?></th>
      <th></th>
      <th align="center"> <?=$tongsoluong;?> </th>
      <th align="center"> <?=number_format($tongtien,0,",",".")?> <? //=$sp->KyHieuTienTe;?> </th>
    </tr>

	</table>
    <div id="cacnutxulygiohang" style="text-align:center;" >
    <input type=button id="btnmuahang" name="btnmuahang" value="<? if($lang=='vi') echo 'Mua hàng'; else echo 'Buy';?>" />
	</div>
 <?php } ?>
</div>
</div>
<div id="giohangan" style=" width:100%; float: left; display:none;">
 </div>